/**
 * 初始化质控病种字典详情对话框
 */
var SdsQcentityInfoDlg = {
    validateFields: {
    	abbrev: {
            validators: {
                notEmpty: {
                    message: '病种缩写不能为空'
                }
            }
        },
    	btDesc: {
            validators: {
                notEmpty: {
                    message: '病种名称不能为空'
                }
            }
        },
    	url: {
            validators: {
                notEmpty: {
                    message: '接口地址不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
SdsQcentityInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdsQcentityInfoDlg.validate = function () {
    $('#sdsQcentityInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsQcentityInfoForm').bootstrapValidator('validate');
    return $("#sdsQcentityInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdsQcentityInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityInfoForm',Sys.backendPath + "/sds/sdsqcentity/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentity.table.refresh();
        SdsQcentityInfoDlg.close();
    });
}

/**
 * 提交修改
 */
SdsQcentityInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityInfoForm',Sys.backendPath + "/sds/sdsqcentity/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentity.table.refresh();
        SdsQcentityInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("sdsQcentityInfoForm", SdsQcentityInfoDlg.validateFields);
    if ($("#linkDepts")) {
        $('#linkDept').combobox('setValues', $("#linkDepts").val().split(","));//多选
    }
});
